package com.components.cachewebview.adapter

import com.tencent.smtt.export.external.interfaces.WebResourceResponse
import java.io.InputStream

class WebResourceResponseAdapter(private var mWebResourceResponse: WebResourceResponse?) :
    WebResourceResponse() {

    companion object {
        fun adapter(webResourceResponse: WebResourceResponse?): WebResourceResponseAdapter {
            return WebResourceResponseAdapter(webResourceResponse)
        }
    }

    override fun getMimeType(): String {
        return mWebResourceResponse?.mimeType ?: ""
    }

    override fun getData(): InputStream? {
        return mWebResourceResponse?.data
    }

    override fun getStatusCode(): Int {
        return mWebResourceResponse?.statusCode ?: -1
    }

    override fun getResponseHeaders(): MutableMap<String, String> {
        return mWebResourceResponse?.responseHeaders ?: mutableMapOf()
    }

    override fun getEncoding(): String {
        return mWebResourceResponse?.encoding ?: ""
    }

    override fun getReasonPhrase(): String {
        return mWebResourceResponse?.reasonPhrase ?: ""
    }

}